
var app = getApp();
var ApiUrl = app.globalData.ApiUrl;
var mph = require("../../utils/util.js");
Page({
  data: {
    winHeight: "",//窗口高度
    currentTab: 0, //预设当前项的值
    scrollLeft: 0, //tab标题的滚动条位置
    contentList:[],
    expertList: [
      // { //假数据
      //   id: 1,
      //   u_name: 'shengqing',
      //   text: '申请售后',
      //   data_list: []
      // },
      { //假数据
        id: 2,
        u_name: 'quanbushouhou',
        text: '全部售后',
        data_list: [
        ]
      }
    ]
  },
  go_order_detail() {
    wx.navigateTo({
      url: '/pages/order_detail/order_detail'
    })
  },
  go_after_sales_type(e) {//跳转售后类型
    let refund_id = e.currentTarget.dataset.refund_id;
    console.log(refund_id);
    wx.navigateTo({
      url: '/pages/commodity_after_sale/commodity_after_sale?refund_id=' + refund_id
    })
  },
  // 滚动切换标签样式
  switchTab: function (e) {
    this.setData({
      currentTab: e.detail.current
    });
    this.checkCor();
  },
  // 点击标题切换当前页时改变样式
  swichNav: function (e) {
    var cur = e.target.dataset.current;
    if (this.data.currentTaB == cur) { return false; }
    else {
      this.setData({
        currentTab: cur
      })
    }
  },
  //判断当前滚动超过一屏时，设置tab标题滚动条。
  checkCor: function () {
    if (this.data.currentTab > 4) {
      this.setData({
        scrollLeft: 300
      })
    } else {
      this.setData({
        scrollLeft: 0
      })
    }
  },
  // add_order_list(state) {
  //   var that = this;
  //   let k = wx.getStorageSync('key');
  //   var url = 'index.php?act=member_order&op=order_list';
  //   mph.postRequest(url, { state_type: state }, function (res) {

  //     if (res.data.code == 200) {
  //       console.log('我的订单列表:', res.data.datas.order_group_list);
  //       let arr = 'expertList[0].data_list';
  //       that.setData({
  //         [arr]: res.data.datas.order_group_list
  //       })
  //     }
  //   });

  // },
  //index.php?act=member_return&op=get_return_list
  get_return_list(){
    var that = this;
    let k = wx.getStorageSync('key');

    var url = 'index.php?act=member_refund&op=get_refund_list';
    let list = {
      key:k
    }
    mph.postRequest(url, list, function (res) {
      console.log('退款记录列表:', res);
      if (res.data.code == 200) {
        console.log('退款记录列表:', res.data.datas.refund_list);
        let arr = 'expertList[0].data_list';
        that.setData({
          [arr]: res.data.datas.refund_list
        })
      }
    });

  },
  onLoad: function (option) {
    let that = this;
    that.get_return_list();
    // that.add_order_list('state_noeval');
    if (option.order_id) {//order_sn
      console.log(option);
    }



    //  高度自适应
    wx.getSystemInfo({
      success: function (res) {
        var clientHeight = res.windowHeight,
          clientWidth = res.windowWidth,
          rpxR = 750 / clientWidth;
        var calc = clientHeight * rpxR - 180;
//console.log(calc)
        that.setData({
          winHeight: calc
        });
      }
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})